package com.example.project.business.extendPoint.BeanPostProcessor;

import java.beans.PropertyDescriptor;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.stereotype.Component;

/**
* @author Hebojin
* @createTime 2023年2月27日 下午2:45:40
* @Description 类描述
*/

@Component
public class TestInstantiationAwareBeanPostProcessor implements InstantiationAwareBeanPostProcessor
{
    
    @Override
    public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException
    {
        if("testPostConstruct".equals(beanName))
        {
            System.out
                    .println(
                            "-----TestInstantiationAwareBeanPostProcessor------postProcessBeforeInstantiation--------------------");
        }
        
        return null;
    }
    
    @Override
    public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException
    {
        if("testPostConstruct".equals(beanName))
    {
        System.out.println("-----TestInstantiationAwareBeanPostProcessor-----postProcessAfterInstantiation---------------------");
        }
        return true;
    }
    
    @Override
    public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName)
            throws BeansException
    {
        if("testPostConstruct".equals(beanName))
        {
        System.out.println("-----TestInstantiationAwareBeanPostProcessor-----postProcessProperties---------------------");
        }
        return null;
    }
    
    @Override
    public PropertyValues postProcessPropertyValues(
            PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException
    {
        if("testPostConstruct".equals(beanName))
        {
        System.out.println("-----TestInstantiationAwareBeanPostProcessor--------postProcessPropertyValues------------------");
        }
        return pvs;
    }
    
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
    {
        if("testPostConstruct".equals(beanName))
        {
            System.out.println("---TestInstantiationAwareBeanPostProcessor----postProcessBeforeInitialization---------");
        }
        return bean;
    }
    
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
    {
        if("testPostConstruct".equals(beanName))
        {
            System.out.println("-----TestInstantiationAwareBeanPostProcessor--postProcessAfterInitialization---------");
        }
        return bean;
    }
}
